Z80/8080 CROSS ASSEMBLER FOR THE
ZILOG Z8 MICROPROCESSOR
A disk-based assembler/ editor compatible with the
ZILOG Z8 Instruction Set
395 Sierra Madre Villa
Pasadena, CA 91107
395 SIERRA MADRE VILLA • PASADENA. CALIFORNIA 91107 • (213)793-5748
I regret being unable to include a personal note. However, there are
a few points which could not be covered in the documentation.
First, I want you to be happy with this software package. If you have
any difficulty — however slight — with either the documentation or the
program, please contact me. I prefer to interact by telephone, but as time
allows I will correspond by mail.
Should program errors arise they will be repaired at no charge. I ask only
that you return your original disk or cassette with proper packaging and a
return manila envelope with sufficient return postage.
Many of the best features of this software were suggested by users, and
your comments and suggestions on the documentation or the program
are welcome. Let's keep in touch.
r \ (
Bringing Up AS MB 1
Interface to TRS DOS 3
ASMB Organization 4
Executive Commands 5
Editor , 8
Scrolling Program Output 8
Assembler Operation 9
Pseudo Operations * 10
Assembler Errors /Diagnostics 12
Sample ASMB Operation 13
BRINGING UP ASMB
Write protect the ASMB disk or cassette.
2. Make a working copy of the master program; store the original as backup.
The ASMB cassette loads at the 500 baud SYSTEM rate.
3. Read the ASMB documentation.
4. ASMB resides in memory immediately after the DOS. In the standard con-
figuration the memory region from 5200H to 7800H is reserved for ASMB
and assembler tables. Neither source nor object files can be located within
this region without damage to the programs.
5. Cassette Load Sequence:
a. Enter ROM BASIC, with cassette 'L' (500 baud rate).
b. Execute SYSTEM command.
Respond to "*?" with
where nnnn is the appropriate file name:
If the assembler is not to be saved on disk then you may branch directly:
If the assembler is to be saved on disk for later, more rapid access,
use the TAPE utility. (The cassett load sequence over-writes the DOS. )
Follow this sequence:
1. TAPE (S=T, B=D)
2. CASS? L
The program will be saved.
ASMB is a powerful disk/tape based editor /assembler system for target processor
program development on a TRS-80 microcomputer.
ASMB includes all the features necessary for the creation, modification and storage
of assembly language programs for the target processor. With minor exceptions,
ASMB features instruction mnemonics identical to the manufacturer's instruction set.
Programs developed with ASMB must be off-loaded for execution by the target pro-
INTERFACE TO TRS DOS
File names communicated to AS MB are terminated by a carriage return. The file
name may be suffixed by an optional unit number. The unit number, if present, must
be separated from the file name by a comma. File names not suffixed by a unit number
default to drive 0.
DISKFILE, refer to file DISKFILE on drive 0.
If a required file is not found in the directory, the file will be created; otherwise it will
Assembly source files are automatically assigned an extension ASM.
All programs use backspace (08) as character delete and BREAK (01) as abort. The
Model I BREAK key may return to TRS DOS. In that event, ASMB must be patched to
use an alternate ABORT key. Change locations 6714H and 5724H from 01 to your
desired ABORT key.* One suggestion might be to change that value to IF and thereby
use the CLEAR key as an abort.
* For later versions of cross-assemblers ASMB-8051, -8070 and -TMS7, these two
locations are 573C and 6809 respectively.
The ASMB program development system consists of a combination text editor, assembler,
and system executive for the creation and modification of assembly language programs.
The system executive is responsible for handling all input /output operations, invoking
the editor or assembler, and dealing with the disposition of source and object files in
The text editor is responsible for the creation and modification of source programs
within the memory file area. The text editor is line-oriented in that editing consists
of entering or deleting source lines identified by ascending line numbers. The editor
features automatic line numbering, line renumbering, moderately free-form source
input, and well-formatted source output.
The assembler performs a two-pass translation of source to object code. The assembler
includes the powerful feature of conditional assembly. Instruction mnemonics are generally
logically and syntactically identical to the manufacturer's instruction set. The assembler
is file-oriented, with up to six source files simultaneously residing in memory. Optional
symbol communication between files enables a moderate block structure development.
Assembly language source programs are maintained in source files under control of
the system executive. Source files are created and deleted by commands to the system
executive. Source code is entered into the source files under control of the editor, and
the assembler can be directed to translate the source file to object code anywhere in
The ASMB editor/assembler resides in memory immediately after the DOS. In the
standard configuration, the memory region from 5200H up to 7500H is reserved for
ASMB and assembler tables. Neither source nor object files can be located within this
region without damage to the programs.
Executive commands consist of a single letter identifier, together with an optional
modifier character, and one or two hexadecimal parameters. The command character (s)
must be separated from any numerical parameters by a single blank. Numerical para-
meters are likewise separated by a blank.
In the following, hexadecimal parameters are indicated by the sequence nnnn or mmmm
while an optional character modifier is indicated by a lower-case c. Unless otherwise
noted, the modifier c is a device control character (0-7), of which only (CRT) and
1 (printer) are supported.
F /NAME /nnnn
F /ERASE /0
Generic file control command. The file control command enables
the user to create or destroy source files. Each source file is
identified by a file NAME of up to five characters. The file name
must be delimited by slashes. The opening slash must be separated
by a blank from the command characters. There is no relation
between memory file NAME and any disk file.
Opens a source file NAME, starting at memory location nnnn,
making NAME the active file. Any previously active files are main-
tained. NOTE : no spaces after the /.
Recall previously active file OTHER, making it the currently active
file. Note that the hexadecimal parameter is absent.
Delete file named ERASE, freeing memory space for a new source
Display the currently active file parameters, file name, starting
and ending memory locations.
Display the file parameters of all memory files.
WT Write currently active source file to tape (500 baud).*
WD Write currently active source file to disk. The executive will respond
with the query FILE. The user must then type the disk file to receive
the source. *
RT Read source code from tape.*
RD Read source code from disk into the currently active memory file.
The executive responds with the FILE query.*
CT n Append a source file from tape, renumbering source lines by increment n.*
CD n Append a disk file to the currently active memory file, renumbering all
source code lines by the increment n.*
* Improperly formed operations, read errors, or insufficient disk file
capacity result in the DISK ERROR or TAPE ERROR diagnostics.
D nnnn mmmm Delete lines numbered nnnn up to and including mmmm from the
source file. If mmmm is omitted only nnnn is deleted.
B (BYE) Return to disk operating system.
I Initialize the system, clearing all source files. The initialization
is automatically performed upon initial entry. No lines of source
code can be entered until a new source file has been defined.
Pc nnnn *** Print a formatted listing of the current source file, starting at line
number nnnn. **
Lc nnnn *** Print an unformatted listing (suppressing line numbers) of the current
source file. **
** The optional modifying character, when present, can be the digit 1
to direct output to list device.
G nnnn Execute at location nnnn; used to enter an auxiliary program, such
as a PROM burner.
A nnnn mmmm*** Assemble the current source file using implied origin (ORG) nnnn
and place the resulting object code into memory starting at location
mmmm. The second parameter is optional; if absent, the object
code is placed into memory at nnnn.
If there is no ORG in your program, the first parameter acts as
ORG nnnn in your program. The code will be assembled as if it is
to run at location nnnn. Most applications, however, require an
execution address in low memory, in conflict with the ROM of the
TRS-80. The second parameter mmmm allows the code to be re-
positioned to available RAM. Thus
will assemble the code for execution at location (first parameter),
and place the object code in memory at B000 (second parameter).
Note that the source file address given in a previous F command
does not appear in the A (assemble) command.
AS Mark existing symbol table for future global reference. (Save
symbol table resulting from last assembly. ) This command, if used,
must follow an assembly: a symbol table must have been generated.
AE nnnn mmmm Assemble, as above, displaying only source code lines containing
an assembler diagnostic.
Release (Mil) the global symbol table.
Print symbol table resulting from previous assembly.
Enter the mini-editor to edit the currently active source file begin-
ning at line nnnn. The mini-editor enables the user to scroll
through the source file, changing source lines on the fly.
Upon entry, the mini-editor displays source line nnnn or the first
source line if nnnn is omitted. The mini-editor then awaits keyboard
input. Depressing any key except up-arrow (5BH) advances the file
pointer to display the next successive line. The up-arrow allows the
user to re-enter the source line starting at character position two.
(At the label field, no line number is required. ) The user-entered
line, terminated by a carriage return, then overlays the old line.
The mini-editor cannot insert new source lines into the file. Return
to system executive via BREAK.
Enter the mini-editor to edit the currently active source file beginning
at the first occurrence of character string STRNG. The string may
be at most five characters long and may contain no blanks. The
string search is operable for the P and L commands as well.
Renumber source lines, starting at nn and incrementing by nn.
The value nn is a decimal parameter.
*** P, L and A command examples: A0 nnnn or Atf nnnn will send the output to the CRT.
Al nnnn or A2 nnnn will send the output to a printer.
Source lines are entered into the currently active source file under control of the file
editor. The system executive recognizes a source line by a four-digit decimal line
number, which must precede every line in the source file. Modifications to the source
file consist of one or more whole lines. Lines may be deleted by the D control command.
Lines may be modified by retyping the line number and entering the new source line.
The editor adjusts the source file to accommodate line length without any wasted file
space. Character deletion is accomplished by the DELETE (—) key.
Source program lines consist of a four-digit number followed by a terminating blank.
The first character of the source line may contain identifiers "*" or ";". These
identifiers proclaim the entire line to be a comment. The label field of the source
line must be separated by exactly one blank from the line number. Identifying labels can
be from one to five characters long and may contain no special characters. The
operation field must be separated from the label field by one or more blanks. The
operand field, if present, must be separated from the operation by a single blank.
Two blanks following the last operand separate the comment field, which should start
with a semicolon. Source lines may be up to 72 characters in length.
The user can invoke automatic line numbering for lines entered into the source file.
In the automatic mode, line numbers are incremented by one from the starting value.
Automatic line numbering is initiated by entering the starting line number followed by
> (greater than). Subsequent entries begin in character position two. The automatic
mode is exited by typing < (less than) following the carriage return for the last source
line - Failure to properly exit the automatic mode can result in erroneous source lines .
Lengthy insertions can be made into an existing source file by renumbering the file
before entering the automatic mode.
SCROLLING PROGRAM OUTPUT
The assembler allows the output to be scrolled. Pressing the space bar will freeze the
display; any other key will resume scroll. Holding the space bar down progresses
output at the repeat rate.
The assembler operates upon the currently active source file only. The source file
consists of a sequence of source lines composed of the four fields: label, operation,
operand, and comment.
The label field, if present, must start in the second character position after the line
number. Entries present in the label field are maintained in a symbol table. These
entries are assigned a value equal to the program counter at the time of assembly,
except that for the SET and EQU pseudo operations the variable defined by the label
field is assigned the value of the operand field. The variables defined by the label field
can be used in the operand field of other instructions either as data constants or locations.
The operation field, separated from the label field by one or more blanks or a colon,
cannot appear before the third character following the line number. Entries in the opera-
tion field must consist of either a valid instruction or one of the several pseudo-operations.
The operand field, separated by a blank from the operation field, consists of an arithmetic
expression containing one or more program variables, constants, or the special character
$, connected by the operators + or -. Evaluation of the operand field is limited to a left-
to-right scan of the expression, using 16-bit integer arithmetic. Operations requiring
multiple operands expect the operands to be separated by a comma.
The special operand $ refers to the program counter at the start of the instruction being
assembled. * The program variable $ can be used as any other program variable, except
that its value changes constantly throughout assembly. The location counter $ allows the
user to employ program-relative computations.
Assembler constants may be either decimal or hexadecimal character strings. Valid
hexadecimal constants must begin with a decimal digit, possibly 0, and be terminated
by the suffix H.
The individual bytes of a 16-bit operand may be accessed as 8-bit operands:
VALUE !H is the high order byte
VALUE ! L is the low order byte
where VALUE is a 16-bit quantity and ! is the ASCII exclamation character with value 21H.
Arithmetic expressions involving string operands must not begin with the string. Example:
8 OH + 'A' is valid
'A' + 80H is invalid
A presentation of the target processor assembly language may be found in the appropriate
*NOTE: Some assemblers interpret $ as the start of the next instruction.
PSEUDO OPERATIONS (expr = arithmetic expression)
Define program counter to nnnn.
Reserve expr bytes of storage.
16-bit datum definition.
8 -bit datum or ASCII character string definition. The
operand may be an ASCII character string enclosed in
single quotation marks. Examples:
DB 'ASCII STRING', 0DH, 0AH
The operand defined by the label field is set equal to the
expression defined by the operand field. This operation
is performed in pass one of the assembly and the var-
iable definition is fixed by the last such definition
The operand defined by the label is set equal to the ex-
pression defined by the operand field. This operation is
performed in both pass 1 and pass 2 and the replacement
is effected upon every encounter.
expr is evaluated. If the result is zero the scanner skips
to the next ENDIF, END, or end of file before resuming
assembly. If the expression evaluates to any non-zero
value, assembly proceeds. Operation is performed in both
Identifies the end of a conditional assembly block.
Allows program assembly to proceed with multiple location
counters. The operation is skipped if the operand has not
previously been defined. The USE operation is best explained
* Neither the IF nor NIF blocks preceding the ENDIF may contain comments
containing the END or END! character sequences.
A ORG SET 100H
BORG SET 200H
f code at 100H j
f code at 200H j
( code |
SET code origin to AORG
SET value of AORG to PC
SET PC to BORG
Resume code at end of
previous block which started
Resume code at END of
block which started at 200H.
Assembler error and diagnostic messages consist of single character identifiers
which flag some irregularity discovered either during pass 1 or pass 2 of the
assembly. The single character precedes the line number of the formatted
P Phase error: the value of the label has changed between the two
L Label error: label contains illegal or too many characters
U Undefined program variable
V Value error: the evaluated operand is not consistent with the operation
S Syntax error
O Opcode error
M Missing label field
A Argument error
R Register error
D Duplicate label error
SAMPLE ASMB OPERATION
ASMB DEVELOPMENT SVSTEM
F --TEST.-- 7500
TEST 7500 7500
I NX 1
00 1 2 ORA
A0O3 C2 OO AO
Create memory file at 7500H
> typed after line number, but not echoed
Auto line mode
< typed after carriage return
Write source to disk
Disk operation completed
Z8 INSTRUCTION SET
REGISTERS AND NOTATION
The notation for operands (condition codes and address modes) and the actual operands
they represent are as follows:
See condition code list below
Working register only-
Register or working regi!
Register pair or working
Rn, where n = 0-15
Indirect working register
Indirect register or working
Indirect working register
Indirect register pair or
working register pair
reg , where reg is an even number in the
range above or a variable whose address
is even; RRp where p = 0, 2, 4, 6. . . 14
@Rn, where n = 0-15
@reg , where reg is as defined above;
@Rn, as defined above
@RRp , where p = 0, 2, 4, 6. . . 14
@reg , where reg is an even number in
the range above, or a variable whose
address is even; @RRp as defined above
reg(Rn) , where reg and Rn are as defined
Program label or expression
Program label or $ + or - offset, where
the location addressed must be in the
range +127, -128 bytes from the start
of the next instruction
#data, where data is an expression
CONDITION CODES AND STATUS FLAGS
Status flags are represented as follows:
The condition codes and the flag settings they represent are:
Greater than or equal
(S XOR V)=0
(S XOR V)=l
(Z OR (S XOR V))=0
Less than or equal
(Z OR (S XOR V))=l
Unsigned greater than or
Unsigned less than
Unsigned greater than
«C=0) & (Z=0))=1
Unsigned less than or
(C OR Z)=l
Note that some of the condition codes correspond to identical flag settings,
NZ-NE, C-ULT, NC-UGE.
ADC dst, src
Add with carry
ADD dst, src
AND dst, src
Complement carry flag
CP dst, src
DJNZ r, dst
Decrement and jump if nonzero
LDRX dst, index, base
LDXR base, index, src
LDC dst, src
LDCI dst, src
LDE dst, src
LDEI dst, src
OR dst, src
Load (except indexed)
Load (indexed). These instructions
replace the Zilog indexed load.
Load constant autoincrement
Load external data
Load external data autoincrement
Reset carry flag
Rotate left through carry
Rotate right through carry
SBC dst, src
Subtract with carry-
Set carry flag
Shift right arithmetic
Set register pointer
SUB dst, src
TCM dst, src
Test complement under mask
TM dst, src
Test under mask
XOR dst, src
Logical exclusive OR
NOTE 1 : These instructions have an identical set of addressing modes, which are
encoded for brevity in this table. The higher opcode nibble is found in the instruction
set table above. The lower nibble is expressed symbolically by a Q in the table, and
its value is found in the following table to the right of the applicable addressing mode
pair. For example, the opcode of an ADC instruction using the addressing modes
r (destination) and Ir (source) is 13.
00 2 E
88 6 C
14 82 64
15 02 04
15 62 E4
16 84 01
16 E4 81
17 84 81
17 E4 01
D6 00 5E
5D 00 5E
FD Q0 5E
ED 00 5E
DD 00 5E
0010 ; WORKING REG
0220 D I
0250 I RET
04 10 RR
0490 LOOP D.JN2
0540 I NC
ISTERS RN 8 LE N LE ±1
OV, LOOP Z8-2
08 7 D
08 3 S
; BELOW ARE
THE INDEXED LORDS
RIO, R0, 248 i IS
248, R8, R18 ; I :
R2, C-RR4 .
t M i
; RELfi LIMIT
} NOTE fflT
REFERS TO STRRT
R6, * +127
.; END RELRTIV
; ERROR CHECK
R4, RR4 ; NO RR
88 D 3
88 E 4
88 E 6
LD R18, 246<R0>
:. LD 240"CR0>, R10
OF DJNZ INSTRUCTION
0OFC 82 4E R -1 ??fl LDE 0RR4, 38 Z8-3
00FE 51 : E4
0190 56 E4
0102 21 06
■ ■ 9
£ a w
§■; - *y
* B #1 _ nn
a s f S3
£ He E5
a |-s2 fc
F ! F
s ^ " g 5 I
a r, u ™ S ■*.
= J R - 8 B
| ^ g E I E
= O — 5 (J EX
S S ° * E i
£ gl | 8 j<£
- " «| 8 E. *
J8£ « II gl
H f- U V • 5 D
) t * ■ 1 » * T3
Ii 1 !'!!!
El< H " s 5 * -
|J L> t £ ii
u l fe * ■< * -
' % * g k -
■ • it-
* t b • „ „ . .
**|S S b
1"= III :
■* ^ ■« St P "^ 5
>-£a w £A- J ac
I 5 = ^ | -g »| .
Et<T" E ?b*
SrK^w E* ^ta- fi
*>< .«t'^ l "tj<-'
5 ^ «° ■„-e - E^r
c . . ^ n — _ "T- .....
*S°fc. , - K o —
« 41 k
V V °
1 V I
U i] <
I H a
W W W M N — (M csl <N >-•
Si M * * * * M
u u u u u u u
g g£££2i£ ££ • ■ «
o oP.ttb3,P.b do o
: » . =
h 1 c a
C O M „
< 2 fc h. S
tin h hJ h bi 2
i ■ ■
S V I
x ^ a
c t >
* * *?
■ ■ s c y. c.
o _ ■ —
8 ■ t if
£■ a o —
- C i
j; it — -:
2 ». js
1 2 i
a I *
■ fe H
a s K
5. « ■
o 5 ii
ii s «
* ■ u
• 1 -
| | z
v " e I *
Ih ^ fl (• n
e a u !! •
£ -z a £ 1
1 E js S ■
9 c C c
1,81 II S
J = E
> 5 ■
X - '
D js N
„ ■ *
o I £
• *- -—
u u C
£ £ -*
ii S H
V £ ■ h
p c E r 4>
l fl j 5
s E ■ y a
> m v ■ _
« BS I- ■—
£ E ■ £
« E o «
• o £ ■
a> ■« <d ^
*. 2 ™ «
1 i ■ t
• I B *
*j «w T3
! i I I
* Qi a,
* M O _
t S 1 3
£ E z N
O O O D
b. h h h
u u w w
« « m «
■ H H H